package com.jy.rhin.model.body.yongyao;


import com.jy.rhin.infra.cda.EDataElement;
import com.jy.rhin.infra.cda.XPath;
import com.jy.rhin.infra.cda.XValid;
import com.jy.rhin.model.CodeObject;
import com.jy.rhin.model.ValueUnit;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author 姚俊
 * @Date 2023/2/9 9:03
 * @Description 用药
 */
@Data
public class YongYao {

    //中药使用类别列表
    @XPath(path = "."
            , listItemPath = "/entry/observation/code[@code='DE06.00.164.00'][@codeSystem='2.16.156.10011.2.2.1']/../value", listItemBackLevel = 0
            , xValid = @XValid(type = "dataElement", dataElement = EDataElement.DE06_00_164_00, nullable = true))
    List<CodeObject> zhongYaoSYLBList = new ArrayList<>();
    //用药条目列表
    @XPath(path = "."
            , listItemPath = "/entry/substanceAdministration", listItemBackLevel = 0)
    List<YongYaoItem> yongYaoItemList = new ArrayList<>();

    public void addZhongYaoSYLB(CodeObject item) {
        zhongYaoSYLBList.add(item);
    }

    public void addYongYaoItem(YongYaoItem item) {
        yongYaoItemList.add(item);
    }

    /**
     * @Description 用药item
     */
    @Data
    public static
    class YongYaoItem {
        //用药途径
        @XPath(path = "/routeCode"
                , xValid = @XValid(type = "dataElement", dataElement = EDataElement.DE06_00_134_00))
        CodeObject yongYaoTJ;
        //单次用药剂量
        @XPath(path = "/doseQuantity"
                , xValid = @XValid(type = "dataElement", dataElement = EDataElement.DE08_50_023_00))
        ValueUnit danCiYYJL;
        //药物使用频率
        @XPath(path = "/rateQuantity"
                , xValid = @XValid(type = "dataElement", dataElement = EDataElement.DE06_00_133_00))
        ValueUnit yaoWuSYPL;
        //药物剂型代码
        @XPath(path = "/administrationUnitCode"
                , xValid = @XValid(type = "dataElement", dataElement = EDataElement.DE08_50_011_00))
        CodeObject yaoWuJX;
        //药品名称
        @XPath(path = "/consumable/manufacturedProduct/manufacturedLabeledDrug/name/text()"
                , xValid = @XValid(type = "dataElement", dataElement = EDataElement.DE08_50_022_00))
        String yaoPinMC;
        //药物类型 CDA文档错误 原始数据元 DE08.05.020.00    DE08.50.025.00
        @XPath(path = "/entryRelationship/observation/code[@code='DE08.05.020.00']/../value/text()"
                , xValid = @XValid(type = "dataElement", dataElement = EDataElement.DE08_05_025_00,nullable = true))
        String yaoWuLX;
        //用药天数
        @XPath(path = "/entryRelationship/observation/code[@code='DE06.00.147.00']/../value"
                , xValid = @XValid(type = "dataElement", dataElement = EDataElement.DE06_00_147_00))
        ValueUnit yongYaoTS;
        //药物使用总剂量
        @XPath(path = "/entryRelationship/observation/code[@code='DE06.00.135.00']/../value"
                , xValid = @XValid(type = "dataElement", dataElement = EDataElement.DE06_00_135_00))
        ValueUnit yaoWuSYZJL;
        //用药停止日期 CDA文档错误 原始数据元 DE06.00.148.00
        @XPath(path = "/entryRelationship/observation/code[@code='DE06.00.134.00']/../value/@value"
                , xValid = @XValid(type = "dataElement", dataElement = EDataElement.DE06_00_148_00))
        String yongYaoTZRQ;
    }
}
